<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<title>MyHomework 作业结果</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" type="text/css" href="css/styles.css">
		<script src="javascript/jquery-1.6.2.min.js" type="text/javascript"></script>
		<script src="javascript/myhomework.js" type="text/javascript"></script>
		<script src="javascript/jquery-ui-1.8.20.custom.min.js" type="text/javascript"></script>
	</head>

	<body>
		<h1 id="login-title">MyHomework</h1>
		<div id="navbox">
		<span class="currentuser"><a href="logout">退出</a></span>
		<span class="currentuser">
				<%
				HttpSession seeion;
				String role = session.getAttribute("role").toString();
				int userId = (Integer) session.getAttribute("user");
				out.println(role + "(" + userId + ")");
			%>
		</span>
    	<ul>
		<li><a href="index">首页</a></li>
		<% 
    		if (role.equals("teacher")|| role.equals("ta")){
   		%> 
    
    	<li><a href="addUser.jsp">添加用户</a></li>
    
    	<% } 
    	%>
		<li><a href="group.action">小组</a></li>
   		<li><a href="homework!showHomework.action">作业</a></li>
    	<li class="current"><a href="homeworkResult!showHomeworkResults.action">作业结果</a></li>
    	<s:if test="role.equals('student')">
    		<li><a href="review.action">组长评审</a></li>
    		</s:if>
    		<s:elseif test="role.equals('ta') || role.equals('teacher')">
    		<li><a href="review.action">评分</a></li>
    		</s:elseif>
    	</ul>
    	<br />
    	</div><br />
    	
		<s:if test="role.equals('student')">
			
			<div id="eachHomework">
    		<div id="content">
    		<p id="introduction-myhomework">我的作业结果：</p><hr />
			<s:if test="myResults.size()>0">
				<ul>
				<s:iterator value="myResults" var="r">
					<li>
					<s:property  value="#r.homework.title"/>_
					<s:property value="#r.title"/>     
					<a href="homeworkResult!download.action?filename=
						<s:property value='#r.filename' />">下载源码 </a>
					</li>
				</s:iterator>
				</ul>
			</s:if>
			<s:else>
			你当前没有作业结果，请提交作业。
			</s:else>
			</div>
			</div>

			
			<div id="eachHomework">
    		<div id="content">
    		<p id="introduction-memberwork">小组成员的作业：</p><hr />
			<s:if test="myGroupResults.size()>0">
				<ul>
				<s:iterator value="myGroupResults" var="r">
				<li>
				<s:property value="#r.student.id"/>_
				<s:property  value="#r.student.name"/>_
				<s:property  value="#r.homework.title"/>_
				<s:property value="#r.title"/>
				<a href="homeworkResult!download.action?filename=
						<s:property value='#r.filename' />">下载源码</a><br />
				<s:if test="">
				
				</s:if>		
				</li>
				</s:iterator>
				</ul>
			</s:if>
			<s:else>
			你小组当前没有作业结果，请及时提交作业。
			</s:else>
			</div>
			</div>
			
			
			<div id="eachHomework">
    		<div id="content">
    		<p id="introduction-allhomework">所有作业：</p><hr />
			<s:if test="allResults.size()>0">
				<ul>
				<s:iterator value="allResults" var="r">
				<li>
				<s:property value="#r.student.id"/>_
				<s:property  value="#r.student.name"/>_
				<s:property  value="#r.homework.title"/>_
				<s:property value="#r.title"/>
				<%--<a href="homeworkResult!download.action?filename=
						<s:property value='#r.filename' />">下载源码</a><br />
				--%></li>
				</s:iterator>
				</ul>
			</s:if>
			<s:else>
			当前没有作业提交结果，请及时提交作业。
			</s:else>
			</div>
			</div>
		</s:if>
		<s:elseif test="role.equals('teacher') || role.equals('ta')">
			<p id="introduction">所有作业：</p>
			<div id="eachHomework">
    		<div id="content">
			<s:if test="allResults.size()>0">
				<ul>
				<s:iterator value="allResults" var="r">
				<li>
				<s:property value="#r.student.id"/>_
				<s:property  value="#r.student.name"/>_
				<s:property  value="#r.homework.title"/>_
				<s:property value="#r.title"/>
				<a href="homeworkResult!download.action?filename=
						<s:property value='#r.filename' />">下载源码</a><br />
				</li>
				</s:iterator>
				</ul>
			</s:if>
			<s:else>
			当前没有作业提交结果。
			</s:else>
			</div>
			</div>
	
		</s:elseif>
		
	</body>
</html>
